<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<script type="text/javascript">
	var grid_ae = null;
	var dialog_ae = null;
	$(function(){
		grid_ae = $("#room_grid").ligerGrid({
				title : '${hotel.name}   房型列表',
                columns: [
                { display: '房间id', name: 'id', isSort : false, width: 120 },
                { display: '名称', name: 'name',isSort : false},
                { display: '床型', name: 'bedType',isSort : false},
                { display: '总房间数', name: 'amount',isSort : false},
                { display: '剩余房间数', name: 'lamount',isSort : false},
                { display: '市场价', name: 'priceMarket',isSort : false},
                { display: '普通价', name: 'priceComA',isSort : false},
                { display: '最低价', name: 'priceMin',isSort : false},
                { display: '创建时间', name: 'gmtCreated',isSort : false,width: 120,
                  render: function(record, rowindex, value, column){
                	 return (new Date(value.time)).format("yyyy年MM月dd日 hh:mm:ss");
                  }
                }, 
                {
                	display: '<a href="javascript:;" onclick="addRoom()">新增房型</a>', 
                	name: 'id',
                	isAllowHide: false, 
                	isSort : false,
                	width: 100,
					render: function (record, rowindex, value, column){
						var html = '<a onclick="priceDetail(\''+ value + '\')" href="javascript:;">特价房</a>&nbsp;<a onclick="editRoom(\''+ value + '\')" href="javascript:;">编辑</a>&nbsp;<a onclick="deleteRoom(\''+ value + '\')" href="javascript:;">删除</a>'; 
						return html; 
					}
                }
                ], 
                pageSize:10,
                root :'list',
                record:'totalRecord',
                url: "/misc/hotel/roomGrid.htm?hotelId=${hotel.id}", 
                width: '99%',height:'99%'
            });


	});
	
	function deleteRoom(roomId){
		$.ligerDialog.confirm('你真的要删除吗？', 
			function (yes){
				if(yes){
					$.post("/misc/hotel/deleteRoom.htm",{roomId:roomId}); 
					grid_ae.loadData();
				}
			});
	}
	
	function editRoom(id){
		dialog_ae = $.ligerDialog.open({ height: 500,width:900, url: "/misc/hotel/editRoom.htm?id="+id, showMax:true,showMin:true,isResize:true,isDrag:false,title:'编辑房型'});
	}
	
	function addRoom(){
		dialog_ae = $.ligerDialog.open({ height: 500,width:900, url: "/misc/hotel/addRoom.htm?hotel=${hotel.id}", showMax:true,showMin:true,isResize:true,isDrag:false,title:'新增房型'});
	
	}
	
	function priceDetail(id){
		dialog_ae = $.ligerDialog.open({ height: 300,width:500, url: "/misc/ticket/roomPriceDetail.htm?roomId="+id, showMax:true,showMin:true,isResize:true,isDrag:false,title:'特价房	'});
	}
</script>

<div id="room_grid" style="margin:0; padding:0"></div>
